<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" >
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
    <script src="/js/axios.js" ></script>
    <script src="/js/vue.js" ></script>
    <link href="/el/element.css" rel="stylesheet"  type="text/css"/>
    <script src="/el/element.js"></script>
    <script src="/js/wangEditor.js"></script>
</head>
<body>
<div id="app">
    <p>
        <el-link  type="primary" href="/api/public/go2Index">返回主页</el-link>
    </p>
<div class="myLogin">
    <h2 style="text-align: center">&nbsp;博客登录&nbsp;</h2>
    <el-divider></el-divider>
    <div >
        <el-input id="name" v-model="user.username" placeholder="请输入帐号">
            <template slot="prepend"><i class="el-icon-s-custom"></i></template>
        </el-input>
    </div>

    <div style="margin-top: 20px;">
        <el-input id="password" v-model="user.password" type="password" placeholder="请输入密码">
            <template slot="prepend"><i class="el-icon-unlock"></i></template>
        </el-input>
    </div>

    <div  style="margin-top: 30px;">
        <el-button id="login" v-on:click="goLogin()" style="width:100%" type="primary" plain>登录</el-button>
    </div>
    <hr>

</div>
</div>
</body>
<script>
    new Vue({
        el:"#app",
        data:{
            user:{
                username:'',
                password:'',
                nickname:'',
            },
        },
        methods:{
            goLogin(){
                this.login=false
                var that = this
                axios({
                    url:"/doLogin",
                    method:"post",
                    headers:{ 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
                    params:this.user
                }).then(
                    function (resq) {
                        console.log(resq.data);
                        if (resq.data.code==0){
                            console.log(resq.data.data);
                            console.log(that.show)
                            that.user =resq.data.data;
                            localStorage.setItem("nickname",resq.data.data.nickname)
                            localStorage.setItem("show",1);
                            localStorage.setItem("show1",1)
                            localStorage.setItem("show2",1)
                            that.$message({
                                showClose: true,
                                offset: 100,
                                message: resq.data.msg,
                                type: 'success'
                            });
                            top.location.href=resq.data.action
                        }else {
                            that.$message({
                                showClose: true,
                                offset: 100,
                                message: resq.data.msg,
                                type: 'error'
                            });
                        }
                    }
                )
            }
            },
        mounted(){

        }
    })



</script>

</html>